﻿
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<style type="text/css">
    .form .formValue input.form-control {
        line-height: 32px;
        padding: 0px;
        resize: none;
        border-radius: 0px;
        box-shadow: none;
        text-indent: 5px
    }

    .textValue {
        width: 100%;
    }

    .selectbox {
        color: #444;
        line-height: 34px;
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        height: 34px;
        width: 100%;
    }

    .search {
        margin-left: 10px;
        padding: 0px;
    }

    table td {
        height: 40px;
        line-height: 40px;
    }

    .zdyPanel {
        background-color: #fff;
        border-top: 1px solid #ddd;
        border-left: 1px solid #ddd;
        border-right: 1px solid #ddd;
        margin: 0px;
        float: left;
        width: 100%;
    }

    .zdyTool {
        float: left;
        padding-left: 10px;
        width: 100%;
    }

    .zdyBar {
        padding: 0px;
        margin: 0px;
        margin-top: 3px;
    }

    .zdyUL {
        list-style-type: none;
        margin: 5px 0px 0px -3px;
        padding: 0px;
    }

        .zdyUL li {
            float: left;
            list-style: none;
            height: 24px;
            line-height: 22px;
        }

            .zdyUL li a {
                cursor: pointer;
                padding: 5px 10px;
                border-radius: 4px;
            }

            .zdyUL li i {
                margin-right: 4px;
                font-size: 13px;
                color: #666;
                vertical-align: middle;
                margin-top: -1px;
            }

            .zdyUL li a:hover {
                text-decoration: none;
                background-color: #1ABC9C;
                color: #fff;
            }

    .autocomplete-suggestions {
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        box-sizing: border-box;
        border: 1px solid #999;
        background: #FFF;
        cursor: default;
        overflow: auto;
        -webkit-box-shadow: 1px 4px 3px rgba(50, 50, 50, 0.64);
        -moz-box-shadow: 1px 4px 3px rgba(50, 50, 50, 0.64);
        box-shadow: 1px 4px 3px rgba(50, 50, 50, 0.64);
    }

    .autocomplete-selected {
        background: #F0F0F0;
    }

    .autocomplete-suggestion {
        padding: 2px 5px;
        white-space: nowrap;
        overflow: hidden;
    }

    .autocomplete-no-suggestion {
        padding: 2px 5px;
    }

    .zdyGirdPanel {
        width: 100%;
        margin: 0px;
        padding: 0px;
        float: left;
    }

    .zdyContentPanel {
        width: 100%;
        margin: 5px 0px 0px 0px;
        padding: 0px;
        float: left;
    }

    .zdyFont {
        padding-left: 5px;
        color: #ff6a00;
    }

    .zdyUL {
        list-style-type: none;
        margin: 5px 0px 0px -3px;
        padding: 0px;
    }

        .zdyUL li {
            float: left;
            list-style: none;
            height: 24px;
            line-height: 22px;
        }

            .zdyUL li a {
                cursor: pointer;
                padding: 5px 10px;
                border-radius: 4px;
                color: #337ab7;
            }

            .zdyUL li i {
                margin-right: 4px;
                font-size: 13px;
                color: #666;
                vertical-align: middle;
                margin-top: -1px;
            }

            .zdyUL li a:hover {
                text-decoration: none;
                background-color: #1ABC9C;
                color: #fff;
            }

    .zdyGirdPanel {
        padding-top: 3px;
    }

    .form .formValue {
        padding: 1px 3px;
    }
</style>

<script>
    $(function () {
        GetItems();
        gridList();
    });

    function GetItems() {
        resultData = getCache("CHECKSea_INDEX");
        if (resultData.length <= 0) {
            $.ajax({
                url: "/CheckManager/CheckInfos/GetHighSeaItemJson",
                dataType: "json",
                async: false,
                success: function (data) {
                    resultData = data;
                    setCache("CHECKSea_INDEX", resultData);
                }, error: function (XMLHttpRequest, textStatus, errorThrown) {
                }
            });
        }
    }

    function InitData(value, type) {
        if (type == "F_Source") {
            var strHtml = "";
            for (var i = 0; i < resultData.resource.length; i++) {
                if (resultData.resource[i].F_ItemCode == value) {
                    strHtml= resultData.resource[i].F_ItemName;
                }
            }
            return strHtml;
        } else if (type == "F_ActivityType") {
            var strHtml = "";
            for (var i = 0; i < resultData.F_ActivityType.length; i++) {
                if (resultData.F_ActivityType[i].F_ItemCode == value) {
                    strHtml= resultData.F_ActivityType[i].F_ItemName;
                }
            }
            return strHtml;
        } else if (type == "F_SiteType") {
            var strHtml = "";
            for (var i = 0; i < resultData.F_SiteType.length; i++) {
                if (resultData.F_SiteType[i].F_ItemCode == value) {
                    strHtml= resultData.F_SiteType[i].F_ItemName;
                }
            }
            return strHtml;
        }
    }

    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "/CheckManager/CheckInfos/GetHighSeaCheckList",
            postData: { },
            height: 670,
            colModel: [
                {
                    label: '操作', name: 'F_Id', width: 120, formatter: function (cellvalue) {
                        var html = '<ul class=\"zdyUL\" style=\"white-space:nowrap;\">';
                        html += '<li>';
                        html += '<a onclick="CheckHighSea(\'' + cellvalue + '\',1)">确认审核</a>';
                        html += '</li>';
                        html += '<li>';
                        html += '<a onclick="CheckHighSea(\'' + cellvalue + '\',0)">驳回</a>';
                        html += '</li>';
                        html += '</ul>';
                        return html;
                    }
                },
                {
                    label: '数据来源', name: 'F_Source', width: 80, align: 'left', formatter: function (cellvalue) {
                        return InitData(cellvalue, 'F_Source');
                    }
                },
                { label: '客户名称', name: 'F_ClientName', width: 120, align: 'left' },
                { label: '活动主题', name: 'F_ActivityTheme', width: 120, align: 'left' },
                {
                    label: '活动类型', name: 'F_ActivityType', width: 80,align: 'left', formatter: function (cellvalue) {
                        return InitData(cellvalue, 'F_ActivityType');
                    }
                },
                { label: '需求金额', name: 'F_DemandCash', width: 80, align: 'left' },
                { label: '活动开始日期', name: 'F_ActivityStartDate', width: 120, align: 'left' },
                { label: '活动结束日期', name: 'F_ActivityEndDate', width: 120, align: 'left' },
                {
                    label: '场地类型', name: 'F_SiteType', align: 'left', width: 120, formatter: function (cellvalue) {
                        return InitData(cellvalue, 'F_SiteType');
                    }
                },
                { label: '申请人', name: 'F_RealName', width: 120, align: 'left' },
                { label: '申请时间', name: 'F_CreatorTime', width: 120, align: 'left' },
                { label: '', name: 'F_Ids', hidden: true },
                { label: '', name: 'F_DemandId', hidden: true },
                { label: '', name: 'F_ClientId', hidden: true },
            ],
            pager: "#gridPager",
            viewrecords: true,
            multiselect: false,
            sortname: '',
            rowNum: 20,
            rowList: [20, 40, 60],
            ondblClickRow: function (rowid, iRow, iCol, e) {
                var rowobj = $("#gridList").jqGridRowValue();
                $.modalOpen({
                    id: "showDemandForm2",
                    title: "需求详情",
                    url: "/ClientManager/ClientInfos/EditDemandForm?DemandId=" + rowobj.F_DemandId + "&F_ClientId=" + rowobj.F_ClientId +  "",
                    width: "1200px",
                    height: "650px",
                    callBack: function (iframeId) {
                        top.frames[iframeId].submitForm();
                    },
                    btn: null
                });
                //var rowobj = $("#gridList").jqGridRowValue();
                //layer.confirm('确认通过审核？', {
                //    btn: ['是', '否']
                //}
                //    , function () {
                //        CheckHighSea(rowobj["F_Ids"], 1);
                //        layer.closeAll('dialog');
                //    }, function () {
                //        CheckHighSea(rowobj["F_Ids"], 2);
                //        layer.closeAll('dialog');
                //    }
                //);
            },
            loadComplete: function (data) {
            }
        });
    }

    function CheckHighSea(orderId, state) {
        if (state == 1) {
            layer.confirm('确认通过审核？', {
                btn: ['是', '否']
            }
                , function () {
                    $.submitForm({
                        url: "/CheckManager/CheckInfos/SubmitCheckHighSea",
                        param: {
                            F_Id: orderId, F_IsCheck: state
                        },
                        success: function () {
                            ReloadGridList();
                            layer.closeAll('dialog');
                        }
                    });
                }, function () {
                    layer.closeAll('dialog');
                }
            );
        } else {
            layer.confirm('确定驳回审核？', {
                btn: ['是', '否']
            }
                , function () {
                    $.submitForm({
                        url: "/CheckManager/CheckInfos/SubmitCheckHighSea",
                        param: {
                            F_Id: orderId, F_IsCheck: state
                        },
                        success: function () {                                                    
                            ReloadGridList();
                            layer.closeAll('dialog');    
                        }
                    });
                }, function () {
                    layer.closeAll('dialog');
                }
            );
        }
        
    }

    function ReloadGridList() {
        var $gridList = $("#gridList");
        $gridList.jqGrid('setGridParam', {
            postData: { },
        }).trigger('reloadGrid');
    }
</script>
<div class="zdyPanel">    
    <div class="zdyBar" style="float:right;white-space:nowrap;width:50%;padding-top:5px;">
        <div style="float:right;padding-right:5px;">
            <div class="btn-group">
                <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
            </div>           
        </div>
    </div>
</div>
<div class="zdyGirdPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>
